home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue71 / CSharp / Delphi / Unit1.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2001-05-20  |  1.9 KB  |  81 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, CheckLst, ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Image1: TImage;
  12.     rgPackage: TRadioGroup;
  13.     clbOptions: TCheckListBox;
  14.     Label1: TLabel;
  15.     btnCalculate: TButton;
  16.     edtCost: TEdit;
  17.     Label2: TLabel;
  18.     procedure btnCalculateClick(Sender: TObject);
  19.     procedure rgPackageClick(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. (* ************************************************************************** *)
  27.  
  28. var
  29.   Form1: TForm1;
  30.  
  31. implementation
  32.  
  33. uses TDMWebLib_TLB, ComObj;
  34.  
  35. {$R *.DFM}
  36.  
  37. procedure TForm1.btnCalculateClick(Sender: TObject);
  38. var obj : _Package;
  39.     cost : double;
  40.     i,options : integer;
  41. begin
  42.     // Create an instance of the C# TDMWebLib object...
  43.     obj := CoPackage.Create;
  44.  
  45.     options:=0;
  46.  
  47.     // figure out which options are set...
  48.     for i:=0 to clbOptions.Items.Count - 1 do
  49.         if clbOptions.checked[i] then
  50.           options := (1 SHL i) + options;
  51.  
  52.     // Simple validation, and we're off...
  53.     if (options > 0) then
  54.     case rgPackage.ItemIndex of
  55.       0: cost := obj.Basic(options);
  56.       1: cost := obj.Advanced(options);
  57.       2: cost := obj.Professional(options);
  58.       else ShowMessage('You must select a Package!');
  59.     end
  60.     else
  61.         ShowMessage('You must select at least one option!');
  62.  
  63.     edtCost.text:=Format('%m',[cost]);
  64. end;
  65.  
  66. (* ************************************************************************** *)
  67.  
  68. procedure TForm1.rgPackageClick(Sender: TObject);
  69. var i : integer;
  70. begin
  71.     edtCost.Text:='';
  72.  
  73.     // Clear the currently selected options...
  74.     for i:=0 to clbOptions.items.count - 1 do clbOptions.Checked[i]:=false;
  75.  
  76.     // 50MB is only available for the Professional Package...
  77.     clbOptions.ItemEnabled[2]:=(Sender as TRadioGroup).ItemIndex = 2;
  78. end;
  79.  
  80. end.
  81.